home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh -e
- #
- # disk: print the current disk space and usage
- # Copyright (C) 2008 Canonical Ltd.
- #
- # Authors: Dustin Kirkland <kirkland@canonical.com>
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, version 3 of the License.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- PKG="byobu"
-
- if [ "$1" = "--detail" ]; then
- df -h -P
- exit 0
- fi
-
- # Default to /, but let users override
- MP="/"
- [ -n "$MONITORED_DISK" ] && MP="$MONITORED_DISK"
- case $MP in
- /dev/*) MP=`grep "$MP" /proc/mounts | awk '{print $2}'` ;;
- esac
-
- disk=`df -h -P "$MP" 2>/dev/null || df -h "$MP"`
- echo "$disk" | tail -n 1 | awk '{print $2 " " $5}' | sed "s/\([^0-9\. ]\)/ \1/g" | awk '{printf "\005{=b MW}%d\005{-}\005{= MW}%sB,\005{-}\005{=b MW}%d\005{-}\005{= MW}%%\005{-} ", $1, $2, $3}'
-